const express = require('express');
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const utils = require('utility');
const userRouter = require('./user');
const app = express();

  app.use(cookieParser());
  app.use(bodyParser.json())

// 解决跨域请求问题  方法一配置响应头start
  app.all('*', function(req, res, next){
  	res.header('Access-Control-Allow-Origin',  '*');
  	res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With, yourHeaderFeild');
  	res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
  	if (req.method === 'OPTIONS'){
    	res.send(200);
  	}
  	else{
    	next();
  	}
});

// 解决跨域请求问题  方法一配置响应头end


app.use('/user',userRouter)
app.listen(9093);
console.log('成功');
